

package jetbrains.buildServer.server.rest;

import java.io.InputStream;
import java.net.URL;

public class SwaggerUIUtil {

  public static final String INDEX = "index.html";
  public static final String RESOURCE_PATH = "swagger/";

  public static InputStream getFileFromResources(String path) {
    String fullPath = RESOURCE_PATH + path;
    ClassLoader classLoader = SwaggerUIUtil.class.getClassLoader();

    URL resource = classLoader.getResource(fullPath);
    if (resource == null) {
      throw new IllegalArgumentException(String.format("File %s was not found", fullPath));
    } else {
      InputStream stream = classLoader.getResourceAsStream(fullPath);
      return stream;
    }

  }
}